package net.whg.controller;

import net.whg.service.ProductService;
import net.whg.util.JsonData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/product/")
public class ProductController {

    @Autowired
    private ProductService productService;

    @GetMapping("init")
    public JsonData init() {
        productService.initProduct();
        return JsonData.buildSuccess();
    }

    @GetMapping("testFeign")
    public JsonData testFeign() {
        productService.testFeign();
        return JsonData.buildSuccess();
    }

    @GetMapping("save")
    public JsonData save(){
        productService.save();
        return JsonData.buildSuccess();
    }

    @GetMapping("list")
    public JsonData list(){
        return JsonData.buildSuccess(productService.list());
    }


}
